package com.webdemo04.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBHandler {
	private Connection conn;
	public DBHandler() {
		try {
			Class.forName("com.mysql.jdbc.Driver");
			String username = "dong";
			String password = "xiaodong";
			String url="jdbc:mysql://localhost/test_struts";
			conn = DriverManager.getConnection(url,username,password);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public static DBHandler newInstance(){
		return new DBHandler();
	}
	public Connection getConnection(){
		return conn;
	}
	
}
